diff --git a/django/views/debug.py b/django/views/debug.py
index 68dba4b500..92c82aa6a5 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -91,7 +91,7 @@ class SafeExceptionReporterFilter:
         value is a dictionary, recursively cleanse the keys in that dictionary.
         """
         try:
-            if self.hidden_settings.search(key):
+            if isinstance(key, str) and self.hidden_settings.search(key):
                 cleansed = self.cleansed_substitute
             elif isinstance(value, dict):
                 cleansed = {k: self.cleanse_setting(k, v) for k, v in value.items()}
